import lombok.extern.slf4j.Slf4j;

@Slf4j
public class VolatileExample {

    private int x = 0;
//    private volatile boolean v = false;
    private boolean v = false;

    public void writer() {
        x = 42;
        v = true;
    }

    public void reader() {
        if (v == true) {
            if (x != 42) {
                log.info("x:" + x);
            }
        }
    }
}
